package com.demo.behavioral.templatemethod;
 
public abstract class AbstractCalculator {

    /*子类需重写的方法*/  
    abstract public int calculate(int num1,int num2);  
    
    /*子类公共方法*/  
    public final int getResult(String exp){  
        String array[] = exp.split("&");  
        int arrayInt[] = new int[2];  
        arrayInt[0] = Integer.parseInt(array[0]);  
        arrayInt[1] = Integer.parseInt(array[1]);  
        return calculate(arrayInt[0],arrayInt[1]);  
    }  
}
